//
//  ZCommentTableViewCell.m
//  DoctorFAQs
//
//  Created by zjq on 17/2/21.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZCommentTableViewCell.h"
#import "ZLabelTools.h"
@interface ZCommentTableViewCell (){
    UIView * _garyView;// 自定义分割线;
}

@end
@implementation ZCommentTableViewCell
- initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initlizeInterface];
    }
    return self;
}

- (void)initlizeInterface {
    [self makeAllSubView];
    [self addAllSubView];
    [self makeAllSubViewMasnoy];
}

- (void)makeAllSubView {
    self.headView = [[UIImageView alloc] init];
    _headView.layer.cornerRadius = 12.5*xsIZE;
    _headView.layer.masksToBounds = YES;
    self.nameLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:self.nameLabel Textcolor:KHGaryColor666 backColor:[UIColor clearColor] Fontsize:13 context:@"歪猴桑" isCenter:NO];
    self.timeLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:self.timeLabel Textcolor:KHGaryColor backColor:[UIColor clearColor] Fontsize:12 context:@"2016-11-2 9:58" isCenter:YES];
    self.replyLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:self.replyLabel Textcolor:[UIColor blackColor] backColor:[UIColor clearColor] Fontsize:15 context:@"医生有点厉害的诶" isCenter:NO];
    _garyView = [[UIView alloc] init];
    _garyView.backgroundColor = MYGRAYCOLOR;
}

- (void)addAllSubView {
    [self.contentView addSubview:self.headView];
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.replyLabel];
    [self.contentView addSubview:_garyView];
}

- (void)makeAllSubViewMasnoy {
    [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(25*xsIZE);
        make.top.equalTo(self.contentView).offset(10*ysIZE);
        make.left.equalTo(self.contentView).offset(10*ysIZE);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headView.mas_right).offset(8*xsIZE);
        make.centerY.equalTo(self.headView);
        make.height.offset(13*ysIZE);
        make.width.offset(100*xsIZE);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-10*xsIZE);
        make.height.offset(13*ysIZE);
        make.width.offset(140*xsIZE);
        make.centerY.equalTo(self.nameLabel);
    }];
    [self.replyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(15*ysIZE);
        make.height.offset(15*ysIZE);
        make.width.offset(150*xsIZE);
    }];
    [_garyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.bottom.equalTo(self.contentView);
        make.height.offset(1.5*ysIZE);
    }];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)setTacticsDetailModel:(TacticsDetailModel *)tacticsDetailModel {
    _tacticsDetailModel = tacticsDetailModel;
    // 头像
    NSString *iconStr = [NSString stringWithFormat:@"%@%@",IconURL,_tacticsDetailModel.pic];
    [self.headView sd_setImageWithURL:[NSURL URLWithString:iconStr] placeholderImage:[UIImage imageNamed:@"icon_center_tx"]];
    // 名字
    self.nameLabel.text = _tacticsDetailModel.name;
    // 时间
    NSString * str = tacticsDetailModel.time;
    NSTimeInterval time = [str doubleValue];
    NSDate *detaildate = [NSDate dateWithTimeIntervalSince1970:time];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"];
    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
    //转化时间戳
    //self.create_time = currentDateStr;
    _timeLabel.text = currentDateStr;
    // 评论内容
    self.replyLabel.text = _tacticsDetailModel.content;
    
}
@end
